#include "headfiles.h"

using namespace std;


int reverseNum(int num) {
    int res = 0;
    bool positive = true;
    if (num < 0) {
        num = 0 - num;
        positive = false;
    }

    int quotient, remainder;
    quotient = num;
    while (quotient > 0) {
        remainder = quotient % 10;
        quotient /= 10;
        res = res * 10 + remainder;
    }

    if (!psoitive) {
        res = 0 - res;
    }

    return res;
}

bool PalindromeNum(int num) {
    if (num < 0) {
        return false;
    }

    int div, r;
    r = num;
    div = 1;
    while (r / 10 > 0) {
        div *= 10;
        r = r % 10;
    }

    int ld, rd;
    r = num;
    while (r / 10 > 0) {
        ld = r / div;
        rd = r % 10;
        if (ld != rd) {
            return false;
        }

        r = r % div;
        r /= 10;
        div = div / 100;
    }

    return true;
}
